﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Convertor.Plugin.SendEmail
{
    class TemplateViewModel : IEquatable<string>, IEquatable<object>
    {
        private static List<TemplateViewModel> templates = new List<TemplateViewModel>();

        public static List<TemplateViewModel> Templates
        {
            get { return TemplateViewModel.templates; }
            set { TemplateViewModel.templates = value; }
        }

        static TemplateViewModel()
        {
            templates.Add(new TemplateViewModel()
            {
                TemplateName = "Gmail",
                TemplateContent = new SmtpClientViewModel()
                {
                    Host = "smtp.gmail.com",
                    LoginName = "@gmail.com",
                    Port = 465,
                    EnableSsl = true
                }
            });
            templates.Add(new TemplateViewModel()
            {
                TemplateName = "Outlook",
                TemplateContent = new SmtpClientViewModel()
                {
                    Host = "smtp.live.com",
                    Port = 587,
                    EnableSsl = true
                }
            });
            templates.Add(new TemplateViewModel()
            {
                TemplateName = "Yahoo Mail",
                TemplateContent = new SmtpClientViewModel()
                {
                    Host = "smtp.mail.yahoo.com",
                    LoginName = "@yahoo.com",
                    Port = 465,
                    EnableSsl = true
                }
            });
            templates.Add(new TemplateViewModel()
            {
                TemplateName = "AT&T",
                TemplateContent = new SmtpClientViewModel()
                {
                    Host = "smtp.att.yahoo.com",
                    Port = 465,
                    EnableSsl = true
                }
            });
            templates.Add(new TemplateViewModel()
            {
                TemplateName = "1&1",
                TemplateContent = new SmtpClientViewModel()
                {
                    Host = "smtp.1and1.com",
                    Port = 587,
                    EnableSsl = true
                }
            });
            templates.Add(new TemplateViewModel()
            {
                TemplateName = "Verizon",
                TemplateContent = new SmtpClientViewModel()
                {
                    Host = "outgoing.verizon.net",
                    LoginName = "@verizon.net",
                    Port = 465,
                    EnableSsl = true
                }
            });
            templates.Add(new TemplateViewModel()
            {
                TemplateName = "86Capital.com",
                TemplateContent = new SmtpClientViewModel()
                {
                    Host = "smtp.exmail.qq.com",
                    Port = 25,
                    LoginName = "@86capital.com",
                    EnableSsl = true
                }
            });
            templates.Add(new TemplateViewModel()
            {
                TemplateName = "Others",
                TemplateContent = new SmtpClientViewModel()
                {
                    Host = "",
                    Port = 25,
                    EnableSsl = false
                }
            });
        }
        private string templateName;

        public string TemplateName
        {
            get { return templateName; }
            set { templateName = value; }
        }
        private SmtpClientViewModel templateContent;

        public SmtpClientViewModel TemplateContent
        {
            get { return templateContent; }
            set { templateContent = value; }
        }

        public override string ToString()
        {
            return TemplateContent.Host;
        }

        public override bool Equals(object obj)
        {
            return this.TemplateContent.Host == obj.ToString();
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        public bool Equals(string other)
        {
            return this.TemplateContent.Host == other;
        }
    }
}
